﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式.组合模式
{
    public class CompositePatternDemo
    {
        public static void Test()
        {
            Employee ceo = new("John", "CEO", 30000);
            Employee headSales = new("Robert", "HeadSales", 20000);
            Employee headMarketing = new("Michel", "Head Marketing", 20000);
            Employee clerk1 = new("Laura", "Marketing", 10000);
            Employee clerk2 = new("Bob", "Marketing", 10000);
            Employee salesExecutive1 = new("Richard", "Sales", 10000);
            Employee salesExecutive2 = new("Rob", "Sales", 10000);

            ceo.Add(headSales);
            ceo.Add(headMarketing);

            headSales.Add(salesExecutive1);
            headSales.Add(salesExecutive2);

            headMarketing.Add(clerk1);
            headMarketing.Add(clerk2);

            foreach(Employee headEmployee in ceo.GetSubordinates())
            {
                Console.WriteLine("HeadEmployee:"+headEmployee);
                foreach(Employee employee in headEmployee.GetSubordinates())
                {
                    Console.WriteLine("\t"+employee);
                }
            }
        }
    }
}
